package com.hucheng.activity.vo;

import com.hucheng.activity.entity.ExchangeDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-15
 * @Description: 返回界面数据
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExchangeVO implements Serializable {
    private Integer exchangeConfigId;
    private String exchangeConfigName;
    private Integer status;
    private String dateStart;
    private String dateEnd;
    private String exchangeRemark;
    private String dateCreated;
    private String dateUpdated;
    private Integer isDel;

    public static ExchangeVO buildExchangeVO(final ExchangeDO exchangeDO) {
        if (exchangeDO == null) {
            return null;
        }
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new ExchangeVO(
                exchangeDO.getExchangeConfigId(),
                exchangeDO.getExchangeConfigName(),
                exchangeDO.getStatus(),
                sdf.format(exchangeDO.getDateStart()),
                sdf.format(exchangeDO.getDateEnd()),
                exchangeDO.getExchangeRemark(),
                dateTimeFormatter.format(exchangeDO.getDateCreated().toLocalDateTime()),
                dateTimeFormatter.format(exchangeDO.getDateUpdated().toLocalDateTime()),
                exchangeDO.getIsDel());
    }
}
